package com.tbit.uqbike.service.event.eventItem;

import com.tbit.uqbike.object.pojo.BrandRemoteConfig;
import com.tbit.uqbike.service.event.EventType;
import org.springframework.context.ApplicationEvent;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * 品牌配置事件
 *
 *
 * @author <a href="mailto:chen.chaoxiong@tbit.com.cn">ChenChaoXiong</a>
 * @since 2024/5/16
 */
public class BrandRemoteConfigEvent extends ApplicationEvent {

    private EventType eventType;
    public BrandRemoteConfigEvent(List<BrandRemoteConfig> source, EventType eventType) {
        super(source);
        this.eventType = eventType;
    }

    public EventType getEventType() {
        return eventType;
    }


    @Override
    public String toString() {
        List<BrandRemoteConfig> source = (List<BrandRemoteConfig>) getSource();
        if (CollectionUtils.isEmpty(source)) {
            return "BrandRemoteConfigEvent{source=[], eventType=" + eventType + '}';
        }
        StringBuilder sourceString = new StringBuilder();
        for (BrandRemoteConfig config : source) {
            sourceString.append(config.toString()).append(", ");
        }

        if (sourceString.length() > 0) {
            sourceString.setLength(sourceString.length() - 2);
        }
        return "BrandRemoteConfigEvent{" +
                "source=[" + sourceString +
                "], eventType=" + eventType +
                '}';
    }
}
